Getting Started
Deploying a Smart Contract
Resources
Get some GO — Ask for some free testnet GO in our Testnet Telegram or buy some on KuCoin to deploy to mainnet
Deploying
Sample Solidity Code
- To get started, copy the code sample below and paste into VS Code in a new file called mytoken.sol
pragma solidity ^0.4.20;
contract MyToken {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* Initializes contract with initial supply tokens to the creator of the contract */
constructor() public {
uint256 initialSupply = 10000;
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply;
}
/* Send coins */
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
return true;
}
}
Compile the code
- Compile the code by clicking on 'compile' or pressing F5
- This will create a few files in a bin/ directory, open MyToken.bin. This contains your contract bytecode, which you’ll use below.
Deploy your Contract
This is really easy using the GoChain Wallet:
- In the top right, choose TestNet
- Click Open Wallet
- Paste your private key for your testnet wallet that has the GO you got from our Telegram
- Click Deploy Contract
- Copy the contents of MyToken.bin into the Bytecode field
- Click Send!
Contract Address
- After a few seconds your contract will be deployed and you’ll get a contract address, copy the address and save it somewhere.
- That address is what people will use to interact with your contract.
Example: 0xd0a6e6c54dbc68db5db3a091b171a77407ff7ccf
Using your new GoChain Contract
- Send GO directly.
- Deploy a DApp
- Using MyEthereWallet
- Using GoChain Wallet